import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)
export default new Vuex.Store({
    state: {
        userName: '游客',
        unionid: 'ow-Ad1C5b0Gd4QMycPY5eGAoT7MU', // 华仔，用于演示彩屏的
        share: {} // app登陆凭证
    },

    mutations: {
        setUserName (state, userName) {
            state.userName = userName
        },
        setUnionid (state, unionid) {
            state.unionid = unionid
        },
        setShare (state, share) {
            for (let k in share) {
                state.share[k] = share[k]
            }
        }
    }
})

// How to use?
// this.$store.commit('decrement', this.price)
// this.$store.dispatch('increase', this.price)
